<!--集体学习信息-->
<template>
  <div class="mui-slider-item mui-control-content">
    <div class="mui-scroll-wrapper">
      <div v-if="initData.insPartyMeetingVo && (!initData.overtimeStatus || initData.overtimeStatus==='0')" class="mui-scroll record-member-lists">
        <ul class="mui-table-view">
          <li class="mui-table-view-cell list-item">
            <b>会议主题：</b><span class="mui-pull-right">{{initData.insPartyMeetingVo.subject}}</span>
          </li>
          <li class="mui-table-view-cell list-item">
            <b>会议状态：</b><span class="mui-pull-right">{{initData.insPartyMeetingVo.statusLabel}}</span>
          </li>
          <li class="mui-table-view-cell list-item">
            <b>创建人：</b><span class="mui-pull-right">{{initData.insPartyMeetingVo.createByName}}</span>
          <li class="mui-table-view-cell list-item">
            <b>会议时间：</b><span class="mui-pull-right">{{fn.formatHM(initData.insPartyMeetingVo.meetTime)}}</span>
          <li class="mui-table-view-cell list-item">
            <b>会议地点：</b><span class="mui-pull-right">{{initData.insPartyMeetingVo.address}}</span>
          </li>
        </ul>
        <div v-if="show()" class="tip-wrap">
          <p class="study-develop" @click="goLookSchedule()" >想了解本次集体学习更多信息？
            <span>点此查看详情></span>
          </p>
          <p class="study-develop" @click="goRelativeSchedule()" >本次集体学习信息不对？
            <span>点此重新查找并关联></span>
          </p>
        </div>
      </div>

      <div class="mui-scroll" v-if="!initData.insPartyMeetingVo && (!initData.overtimeStatus || initData.overtimeStatus==='0')">
        <div class="statistics-lists group-study">
          <p class="study-tips">提示：还未开展集体学习，请点击下方按钮及时添加</p>
          <div class="sign-end-btn" @click="goScheduleAdd()">添加集体学习</div>
          <p @click="goRelativeSchedule()" class="study-develop">本次集体学习已开展？<span>点击查找已添加的集体学习&gt;</span></p>
        </div>
      </div>

      <div class="mui-scroll" v-if="initData.overtimeStatus==='1'">
        <div class="statistics-lists group-study">
          <p class="study-tips">提示：集体学习已过期，请点击下方按钮申请补开，超过三个月补开的不加分</p>

          <!-- 申请补开集体学习该按钮显示 -->
          <div v-if="initData.patchUpApproveStatus!=='1'" class="sign-end-btn" @click="goApply(initData)">申请补开集体学习</div>

          <!-- 集体学习补开申请中该按钮显示 -->
          <div v-if="initData.patchUpApproveStatus==='1'" class="sign-start-btn">集体学习补开申请中</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import tools from '@/utils/tools'
  import loginService from '@/service/loginService'
  export default {
    name: 'studyDetails',
    props: {
      initData: {
        type: Object,
        default: {}
      }
    },
    data () {
      return {
        fn: tools,
        data: {},
        tabIndex: 0
      }
    },
    created () {
      delete this.$store.state.addScheduleStudy
    },
    methods: {
      loadData () {
        let pkId = this.initData.meetingId
        loginService.getPubsherMeetingInfoByPkId(pkId).then((res) => {
          if (res.code !== 200) {
            return tools.tip(res.describe === '未查询到资源' ? '已无更多数据' : res.describe)
          }
          this.data = res.data
          if (this.data.insPartyMeetingResponseModel.discussContent) {
            this.discussContent = this.data.insPartyMeetingResponseModel.discussContent
          }
          if (this.data.insPartyMeetingResponseModel.recordContent) {
            this.recordContent = this.data.insPartyMeetingResponseModel.recordContent
          }
          if (this.data.insPartyMeetingResponseModel.noticeFile && this.data.insPartyMeetingResponseModel.noticeFile !== '') {
            this.files = JSON.parse(this.data.insPartyMeetingResponseModel.noticeFile)
          }
          if (this.data.insPartyMeetingResponseModel.resultFile && this.data.insPartyMeetingResponseModel.resultFile !== '') {
            this.attachmentList = JSON.parse(this.data.insPartyMeetingResponseModel.resultFile)
          }
        })
      },
      // 查看关联的会议详情
      goLookSchedule () {
        this.$router.push({'path': '/scheduleDetail/' + this.initData.meetingId})
      },
      // 跳转到添加组织生活，并带上参数
      goScheduleAdd () {
        if (!this.show()) {
          return tools.tip("您没有操作权限")
        }
        if (!this.$store.state.scheduleAddData) {
          this.$store.state.scheduleAddData = {}
        }
        this.$store.state.scheduleAddData.subject = this.initData.subject
        this.$store.state.scheduleAddData.typeLabel = '集体学习'
        this.$store.state.scheduleAddData.type = '5'
        // 添加集体学习标识
        this.$store.state.addScheduleStudy = true
        this.$store.state.weekId = this.$route.params.weekId
        this.$router.push({'name': 'scheduleAdd'})
      },
      // 关联集体学习
      goRelativeSchedule () {
        if (!this.show()) {
          return tools.tip("您没有操作权限")
        }
        this.$router.push({'path': '/searchCollectiveStudy/' + this.$route.params.weekId})
      },
      goApply (data) {
        this.$store.state.studyRepairApply = data
        this.$router.push({'path': `/repairApply`})
      },
      show () {
        let roleType = this.$store.state.roleType || ''
        return tools.hasRoleType(roleType)
      }
    }
  }
</script>

<style scoped>

</style>
